package com.wds.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wds.common.utils.BeanCopyUtils;
import com.wds.domain.JsonResult;
import com.wds.domain.entity.Link;
import com.wds.domain.type.SystemConstants;
import com.wds.domain.vo.LinkVo;
import com.wds.mapper.LinkMapper;
import com.wds.service.LinkService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 友链(Link)表服务实现类
 *
 * @author wds
 * @since 2022-10-21 15:50:18
 */
@Service("linkService")
public class LinkServiceImpl extends ServiceImpl<LinkMapper, Link> implements LinkService {

    @Override
    public JsonResult<Object> getAllLink() {
        LambdaQueryWrapper<Link> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Link::getStatus, SystemConstants.LINK_STATUS_NOT_PASS);
        List<Link> links = list(queryWrapper);

        List<LinkVo> linkVos = BeanCopyUtils.copyList(links, LinkVo.class);
        return JsonResult.ok(linkVos);
    }
}

